package com.cjbdi.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.hibernate.SQLQuery;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cjbdi.util.NumUtil;


/**
 * SpzxxlzsService
 */
@Service
@Transactional
public class SpzxxlzsService{
	@Autowired  
    @PersistenceContext  
    private EntityManager entityManager;// 注入EntityManager实例 
	@Autowired
	BaseService baseService;
	//审判/执行效率指数概述（和去年同比） 
	public List getGsList(String kind,String type, String date, String fybm,String casetype){ 
    	Query query = entityManager.createNativeQuery("select date,jbfy,fymc,yj,cbr,xl,result from sfzs_result_spzxxl where casetype='"+casetype+"' and type='"+type+"' and date in('"+date+"','"+(Integer.parseInt(date)-1)+"') and kind='"+kind+"' and jbfy='"+fybm+"' order by date desc");  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }
    //附表表格
    public List getFbList(String type, String date, String fybm,String casetype, String kind){  
    	StringBuffer sql = new StringBuffer("select fyjc,yj,cbr,xl,result from sfzs_result_spzxxl,sfzs_czrk where sfzs_result_spzxxl.jbfy=sfzs_czrk.fybm and sfzs_czrk.year='"+date+"' and casetype='"+casetype+"' and type='"+type+"' and date ='"+date+"' and kind='"+kind+"' and ");
    	if(kind.equals("高")) {
    		sql.append("jbfy not in('X00','000','ZZ0')");
    	}else {
    		sql.append("jbfy like'"+fybm.substring(0, 1)+"%'");
    	}
    	sql.append(" order by result desc");
    	Query query = entityManager.createNativeQuery(sql.toString());  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList(); 
        for(int i=0;i<rows.size();i++) {
			Map row = (Map)rows.get(i);
			row.put("id", i+1);
		}
        return rows;
    }
    //全国排名表格
    /*public List getQgTableList(String type, String date, String casetype, boolean isQuanguo){ 
    	StringBuffer sql = new StringBuffer("select jbfy,fy,lastyearzs,yearzs,cz,rank() over(order by yearzs desc) as rank from(SELECT jbfy,fymc as fy,\r\n" + 
    			"sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )as lastyearzs,\r\n" + 
    			"sum(case when date='"+date+"' then result else 0 end) as yearzs,\r\n" + 
    			"(sum(case when date='"+date+"' then result else 0 end) - sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )) as cz from sfzs_result_spzxxl where (jbfy not in('X00','000') or jbfy is null)");
    	if(isQuanguo) {
    		sql.append(" and fymc='全国'");
    	}else {
    		sql.append(" and fymc!='全国'");
    	}
    	sql.append(" and type='"+type+"' and date in('"+date+"','"+(Integer.parseInt(date)-1)+"') and kind ='高' and casetype='"+casetype+"' GROUP BY jbfy,fymc)t");
    	Query query = entityManager.createNativeQuery(sql.toString());  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    //中院排名表格
   /* public List getZjTableList(String type, String date, String fybm,String casetype){ 
    	String sql = "SELECT jbfy,fyjc as fy,\r\n" + 
        			"sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )as lastyearzs,\r\n" + 
        			"sum(case when date='"+date+"' then result else 0 end) as yearzs,\r\n" + 
        			"(sum(case when date='"+date+"' then result else 0 end) - sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )) as cz from sfzs_result_spzxxl,sfzs_czrk where sfzs_result_spzxxl.jbfy=sfzs_czrk.fybm and type='"+type+"' and sfzs_czrk.year='"+date+"' and kind ='中' and casetype='"+casetype+"' and jbfy like'"+fybm.substring(0, 1)+"%' GROUP BY fyjc,jbfy ORDER BY yearzs desc";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    //辖区排名表格
    /*public List getXqTableList(String type, String date, String fybm,String casetype){  
    	String sql = "SELECT jbfy,replace(fymc,'人民法院','法院') as fy,\r\n" + 
    			"sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )as lastyearzs,\r\n" + 
    			"sum(case when date='"+date+"' then result else 0 end) as yearzs,\r\n" + 
    			"(sum(case when date='"+date+"' then result else 0 end) - sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )) as cz from sfzs_result_spzxxl where kind ='辖' and type ='"+type+"' and casetype='"+casetype+"' and jbfy like'"+fybm.substring(0, 2)+"%' and jbfy<>'"+fybm.substring(0, 2)+"'||'0' and right(fymc,5)<>'（已撤销）' GROUP BY jbfy,fymc ORDER BY yearzs desc";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    //区县法院在所属高院辖区内排名
    /*public List getRankInGyxq(String type, String date, String fybm,String casetype){  
    	String sql = "SELECT\r\n" + 
    			"	rank \r\n" + 
    			"FROM\r\n" + 
    			"	(\r\n" + 
    			"SELECT\r\n" + 
    			"	jbfy,\r\n" + 
    			"	fy,\r\n" + 
    			"	lastyearzs,\r\n" + 
    			"	yearzs,\r\n" + 
    			"	cz,\r\n" + 
    			"	rank ( ) over ( ORDER BY yearzs DESC ) AS rank \r\n" + 
    			"FROM\r\n" + 
    			"	(\r\n" + 
    			"SELECT\r\n" + 
    			"	jbfy,\r\n" + 
    			"	REPLACE ( fymc, '人民法院', '法院' ) AS fy,\r\n" + 
    			"	SUM( CASE WHEN DATE = '"+(Integer.parseInt(date)-1)+"' THEN RESULT ELSE 0 END ) AS lastyearzs,\r\n" + 
    			"	SUM( CASE WHEN DATE = '"+date+"' THEN RESULT ELSE 0 END ) AS yearzs,\r\n" + 
    			"	(\r\n" + 
    			"	SUM( CASE WHEN DATE = '"+date+"' THEN RESULT ELSE 0 END ) - SUM( CASE WHEN DATE = '"+(Integer.parseInt(date)-1)+"' THEN RESULT ELSE 0 END ) \r\n" + 
    			"	) AS cz \r\n" + 
    			"FROM sfzs_result_spzxxl" +
    			" 	WHERE\r\n" + 
    			"	kind = '辖' \r\n" + 
    			"	AND TYPE = '"+type+"' \r\n" + 
    			"	AND jbfy LIKE '"+fybm.substring(0, 1)+"%' \r\n" + 
    			"	AND casetype = '"+ casetype +"'" +
    			"	AND RIGHT ( jbfy, 1 ) <> '0' \r\n" + 
    			"	AND RIGHT ( fymc, 5 ) <> '（已撤销）' \r\n" + 
    			"GROUP BY\r\n" + 
    			"	jbfy,\r\n" + 
    			"	fymc \r\n" + 
    			"ORDER BY\r\n" + 
    			"	yearzs DESC \r\n" + 
    			"	) t \r\n" + 
    			"	) t1 \r\n" + 
    			"WHERE\r\n" + 
    			"	jbfy = '"+fybm+"'";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    //附表表格（区县）
    public List getFbQxList(String type, String date, String fybm,String casetype){  
    	String sql = "select replace(fymc,'人民法院','法院') as fyjc,yj,cbr,xl,result from sfzs_result_spzxxl where type='"+type+"' and casetype='"+casetype+"' and sfzs_result_spzxxl.date ='"+date+"' and kind='辖' and jbfy like'"+fybm.substring(0, 2)+"%' and right(fymc,5)<>'（已撤销）' order by result desc";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }
    //附表表格（区县本身）
    public List getFbQxSelfList(String type, String date, String fybm,String casetype){  
    	String sql = "select replace(fymc,'人民法院','法院') as fyjc,yj,cbr,xl,result from sfzs_result_spzxxl where type='"+type+"' and casetype='"+casetype+"' and sfzs_result_spzxxl.date ='"+date+"' and kind='辖' and jbfy ='"+fybm+"' order by result desc";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }
    //同等规模城市排名表格
    /*public List getTdZjTableList(String type, String date, String fybm,String casetype){  
    	String sql = "SELECT jbfy,replace(fyjc,'法院','')||'法院' AS fy,\r\n" + 
    			"sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )as lastyearzs,\r\n" + 
    			"sum(case when date='"+date+"' then result else 0 end) as yearzs,\r\n" + 
    			"(sum(case when date='"+date+"' then result else 0 end) - sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )) as cz from sfzs_result_spzxxl,sfzs_czrk where sfzs_result_spzxxl.jbfy=sfzs_czrk.fybm and type='"+type+"' and casetype='"+casetype+"' and sfzs_czrk.year='"+date+"' and (kind = '中' or (kind='高' and fybm in('100','200','900','M00'))) and size in (select size from sfzs_czrk where sfzs_czrk.year='"+date+"' and fybm = '"+fybm+"') GROUP BY jbfy,fyjc ORDER BY yearzs desc";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }
    //同等直辖市中院排名表格
    public List getTdZxTableList(String type, String date, String fybm,String casetype){  
    	String sql = "SELECT jbfy,fyjc as fy,\r\n" + 
    			"sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )as lastyearzs,\r\n" + 
    			"sum(case when date='"+date+"' then result else 0 end) as yearzs,\r\n" + 
    			"(sum(case when date='"+date+"' then result else 0 end) - sum(case when date='"+(Integer.parseInt(date)-1)+"' then result else 0 end )) as cz from sfzs_result_spzxxl,sfzs_czrk where sfzs_result_spzxxl.jbfy=sfzs_czrk.fybm and type='"+type+"' and casetype='"+casetype+"' and sfzs_czrk.year='"+date+"' and kind ='辖' AND (jbfy like'1%0' or jbfy like'2%0' or jbfy like'9%0' or jbfy like'M%0' )\r\n" + 
    					"	AND jbfy not in('100','200','900','M00') GROUP BY jbfy,fyjc ORDER BY yearzs desc";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    //直辖市中院排名表格
    /*public List getZjZxTableList(String type, String date, String fybm,String casetype){  
    	StringBuffer sql = new StringBuffer( "SELECT\r\n" + 
    			"	jbfy,\r\n" + 
    			"	fyjc AS fy,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN result ELSE 0 END ) AS lastyearzs,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN result ELSE 0 END ) AS yearzs,\r\n" + 
    			"	(\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN result ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN result ELSE 0 END ) \r\n" + 
    			"	) AS cz \r\n" + 
    			"FROM\r\n" + 
    			"	sfzs_result_spzxxl,\r\n" + 
    			"	sfzs_czrk \r\n" + 
    			"WHERE\r\n" + 
    			"	sfzs_result_spzxxl.jbfy = sfzs_czrk.fybm \r\n" + 
    			"	AND type = '"+type+"' \r\n" + 
    			"	AND sfzs_czrk.YEAR = '"+date+"' \r\n" + 
    			"	AND kind = '辖' AND casetype='"+casetype+"'" + 
    			"	AND jbfy LIKE '"+fybm.substring(0, 1)+"%' AND right(jbfy,1)='0' AND jbfy <>'"+fybm.substring(0, 1)+"00'\r\n" + 
    			"GROUP BY\r\n" + 
    			"	jbfy,\r\n" + 
    			"	fyjc \r\n" + 
    			"ORDER BY\r\n" + 
    			"	yearzs desc");
    	Query query = entityManager.createNativeQuery(sql.toString());  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }
  //同等收案量排名表格
    public List getTdSalTableList(String type, String date, String fybm, String casetype){  
    	StringBuffer sql = new StringBuffer("SELECT\r\n" + 
    			"	sal,jbfy,\r\n" + 
    			"	REPLACE ( fyjc, '法院', '' ) || '法院' AS fy,\r\n" + 
    			"	result\r\n" + 
    			"FROM sfzs_result_spzxxl," + 
    			"	sfzs_czrk \r\n" + 
    			"WHERE\r\n" + 
    			"sfzs_result_spzxxl.jbfy = sfzs_czrk.fybm \r\n" + 
    			"	AND type = '"+type+"' AND casetype='"+casetype+"'" + 
    			"	AND sfzs_czrk.YEAR = '"+date+"' \r\n" + 
    			"	AND sfzs_result_spzxxl.date = '"+date+"'\r\n" + 
    			"	AND kind = '中' \r\n" + 
    			"	AND sal IN ( SELECT sal FROM sfzs_czrk WHERE sfzs_czrk.YEAR = '"+date+"' AND fybm = '"+fybm+"' ) ORDER BY result desc\r\n");
 
    	Query query = entityManager.createNativeQuery(sql.toString());  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    //区县法院基本信息
   /* public List getQxInfo(String date,String fybm,String casetype,String type){  
    	String sql = "select (select count(*) from sfzs_czrk where sfzs_czrk.year='"+date+"' and size in (select size from sfzs_czrk where sfzs_czrk.year='"+date+"' and fybm = '"+fybm+"')) as c,(select fyjc from sfzs_czrk where sfzs_czrk.year='"+date+"' and fybm = '"+fybm.substring(0, 1)+"'||'00') as xq,num,jbfy,fy,rank,size from(select num,jbfy,fy,result,size,rank() over(order by result desc) as rank from(select size,num,jbfy,fyjc as fy,result from sfzs_result_spzxxl,sfzs_czrk where sfzs_result_spzxxl.jbfy=sfzs_czrk.fybm and type='"+type+"' and casetype='"+casetype+"' and sfzs_czrk.year='"+date+"' and kind ='中' and date='"+date+"' and size in (select size from sfzs_czrk where sfzs_czrk.year='"+date+"' and fybm = '"+fybm+"') order by result desc) t )t1 where jbfy='"+fybm+"'";
    	Query query = entityManager.createNativeQuery(sql);  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }*/
    public void getSpZxzsGy(Map dataMap,String kind,String type, String date, String fybm,String fymc,String casetype) {//裁判文书审判效率指数
    	getSectionOne(dataMap,kind,type,date,fybm,casetype);
		List qgTableList = baseService.getQgTableList("sfzs_result_spzxxl", type, date, false, true, casetype);
		List qgSelfList = baseService.getQgTableList("sfzs_result_spzxxl", type, date, true, true, casetype);
		List qgTableList3 = new ArrayList();
		Map rowSelf = new HashMap();
		for(int i=qgTableList.size()-1;i>=0;i--) {//为全国报告增加
			Map row = (Map)qgTableList.get(i);
			String fy = row.get("fy").toString();
			if(fy.contains("北京")||fy.contains("天津")||fy.contains("上海")||fy.contains("重庆")) {
				continue;
			}else {
				dataMap.put("spxl_"+casetype+"zs_rank1_qg",NumUtil.toSheng(fy.toString())+"法院");
				if(fymc.equals("全国")) {
					List zjList = baseService.getZjTableList("sfzs_result_spzxxl",type, date, row.get("jbfy").toString(),true, casetype);
					Map rowzj = (Map)zjList.get(0);
					String rankZJ1 = rowzj.get("fy").toString();
					if(casetype.equals("sp")) {
						dataMap.put(9,NumUtil.toSheng(fy.toString()));
					}else {
						dataMap.put(11,NumUtil.toSheng(fy.toString()));
					}
					dataMap.put("spxl_"+casetype+"zs_rank1_zj", rowzj.get("fy").toString());//中级排名第一
				}
				break;
			}
		}
		baseService.getGyDataIntoMap(dataMap, qgTableList, qgSelfList, qgTableList3, fymc, "spxl_"+casetype+"zs");
		List zjTableList = baseService.getZjTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
		List gylist = baseService.getSelfZs("sfzs_result_spzxxl", type, date, fybm, casetype);
		baseService.getZyDetailDataIntoMap(dataMap, zjTableList, gylist, fymc, "spxl_"+casetype+"zs");
		
		//处理表格
		if(casetype.equals("sp")) {
			if(fymc.equals("全国")) {
				dataMap.put("array4",qgTableList);
				List fbList = getFbList(type,date,fybm,casetype,"高");
				dataMap.put("array39",fbList);
			}else {
				List fbList = getFbList(type,date,fybm,casetype,"中");
				dataMap.put("array7",qgTableList3);
				dataMap.put("array8",zjTableList);
				dataMap.put("array40",fbList);
			}
		}else {
			if(fymc.equals("全国")) {
				dataMap.put("array5",qgTableList);
				List fbList = getFbList(type,date,fybm,casetype,"高");
				dataMap.put("array40",fbList);
			}else {
				List fbList = getFbList(type,date,fybm,casetype,"中");
				dataMap.put("array9",qgTableList3);
				dataMap.put("array10",zjTableList);	
				dataMap.put("array41",fbList);
			}
			
		}
		
    } 
    public void getSpZxzsZy(Map dataMap,String kind, String type, String date, String fybm ,String fymc,String casetype) {//裁判文书公开指数    	
    	
		List zjTableList = new ArrayList();
		List tdTableList = new ArrayList();
		List xqTableList = new ArrayList();
		List tsTableList = new ArrayList();
		
		xqTableList = baseService.getXqTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
		List zylist = baseService.getSelfZs("sfzs_result_spzxxl", type, date, fybm, casetype);
		baseService.getQxDetailDataIntoMap(dataMap, xqTableList, zylist, fymc, "spxl_"+casetype+"zs");
		
		tsTableList = baseService.getTsTableList("sfzs_result_spzxxl", type, date, fybm, true, casetype);
    	baseService.getTsDataIntoMap(dataMap, tsTableList, fybm, "spxl_"+casetype+"zs");
		
		if(fybm.startsWith("1")||fybm.startsWith("2")||fybm.startsWith("M")||fybm.startsWith("9")) {
			getSectionOne(dataMap,"辖",type,date,fybm,casetype);
			tdTableList = baseService.getTdZxTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
			baseService.getTdZxDataIntoMap(dataMap, tdTableList, fybm, "spxl_"+casetype+"zs");
			zjTableList = baseService.getZjZxTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
			baseService.getZyDataIntoMap(dataMap, zjTableList, fybm, "spxl_"+casetype+"zs");
		}else {
			getSectionOne(dataMap,kind,type,date,fybm,casetype);
			List infoList = baseService.getQxInfo("sfzs_result_spzxxl",type, date, fybm, true, casetype);
			tdTableList = baseService.getTdZjTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
			baseService.getTdCityDataIntoMap(dataMap, infoList, tdTableList, "spxl_"+casetype+"zs",fybm);
			zjTableList = baseService.getZjTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
			baseService.getZyDataIntoMap(dataMap, zjTableList, fybm, "spxl_"+casetype+"zs");
			//同等收案量排行
			List tdSalTableList = baseService.getTdSalTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
			baseService.getTdSalDataIntoMap(dataMap, tdSalTableList, fymc,"spxl_"+casetype+"zs");	
		}
		List fbList = getFbQxList(type, date, fybm, casetype);
		baseService.handleFb(fbList, fymc);
		//处理表格
		if(casetype.equals("sp")) {
			
			if(fybm.startsWith("1")||fybm.startsWith("2")||fybm.startsWith("M")||fybm.startsWith("9")) {
				dataMap.put("array10",zjTableList);
				dataMap.put("array11",tdTableList);
				dataMap.put("array12",xqTableList);
				dataMap.put("array13",tsTableList);
				dataMap.put("array65",fbList); 
			}else {
				dataMap.put("array10",zjTableList);
				dataMap.put("array11",tdTableList);
				dataMap.put("array12",xqTableList);
				dataMap.put("array13",tsTableList);
				dataMap.put("array69",fbList); 
			}
		}else {
			if(fybm.startsWith("1")||fybm.startsWith("2")||fybm.startsWith("M")||fybm.startsWith("9")) {
				dataMap.put("array14",zjTableList);
				dataMap.put("array15",tdTableList);
				dataMap.put("array16",xqTableList);
				dataMap.put("array17",tsTableList);
				dataMap.put("array66",fbList); 
			}else {
				dataMap.put("array14",zjTableList);
				dataMap.put("array15",tdTableList);
				dataMap.put("array16",xqTableList);
				dataMap.put("array17",tsTableList);
				dataMap.put("array70",fbList); 
			}
		}
		
	}
    
    public void getQxZs(Map dataMap,String kind, String type, String date, String fybm, String casetype) {//区县法院指数
    	getSectionOne(dataMap,kind,type,date,fybm,casetype);
    	List xqTableList = baseService.getXqTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
    	List gylist = baseService.getGyOrZyXqZs("sfzs_result_spzxxl", type, date, fybm, casetype,"高");
    	List zylist = baseService.getGyOrZyXqZs("sfzs_result_spzxxl", type, date, fybm, casetype,"中");
    	baseService.getQxDataIntoMap(dataMap, xqTableList, fybm, "spxl_"+casetype+"zs",gylist,zylist);
    	String ssxq_gy_rank = baseService.getRankInGyxq("sfzs_result_spzxxl",type, date, fybm, true, casetype).get(0).toString();
    	dataMap.put("spxl_"+casetype+"zs_rank_gy",  "第" + NumUtil.toChineseNum(ssxq_gy_rank) + "位");
    	List tsTableList = baseService.getTsTableList("sfzs_result_spzxxl",type, date, fybm, true, casetype);
    	baseService.getTsDataIntoMap(dataMap, tsTableList, fybm, "spxl_"+casetype+"zs");
    	List fbList = getFbQxSelfList(type, date, fybm, casetype);
		for(int i=0;i<fbList.size();i++) {
			Map row = (Map)fbList.get(i);
			row.put("id", i+1);
			row.put("lv", NumUtil.toNxiaoshu(row.get("result").toString(), 2)+"%");
		}
    	if(casetype.equals("sp")) {
    		dataMap.put("array4",xqTableList);
    		dataMap.put("array5",tsTableList);
    		dataMap.put("array33",fbList); 
    	}else {
    		dataMap.put("array6",xqTableList);
    		dataMap.put("array7",tsTableList);
    		dataMap.put("array34",fbList); 
    	}
    	
    }
    
    public void getSectionOne(Map dataMap,String kind,String type, String date, String fybm, String casetype) {
    	List gslist = getGsList(kind,type,date,fybm,casetype);//获取执行指数概况
    	Map mapYear = new HashMap();
    	Map mapLastYear = new HashMap();
    	double zs = 0;
    	double zsLastYear = 0;
    	double xl = 0;
    	double xlLastYear = 0;
    	double rjja = 0;
    	double rjjaLastYear = 0;
    	if(gslist.size()>1) {
    		mapYear = (Map)gslist.get(0);
        	mapLastYear = (Map)gslist.get(1);
        	zs = NumUtil.toNxiaoshu(mapYear.get("result").toString(), 2);
        	zsLastYear = NumUtil.toNxiaoshu(mapLastYear.get("result").toString(), 2);
        	xl = NumUtil.toNxiaoshu(mapYear.get("xl").toString(),3);
        	xlLastYear = NumUtil.toNxiaoshu(mapLastYear.get("xl").toString(),3);
        	rjja = NumUtil.toNxiaoshu(Double.parseDouble(mapYear.get("yj").toString())/Double.parseDouble(mapYear.get("cbr").toString()),1); 
    		rjjaLastYear = NumUtil.toNxiaoshu(Double.parseDouble(mapLastYear.get("yj").toString())/Double.parseDouble(mapLastYear.get("cbr").toString()),1); 
        	
    	}
    	dataMap.put("spxl_"+casetype+"zs", zs);
		dataMap.put("spxl_"+casetype+"zs_lastyear", zsLastYear);
		dataMap.put("spxl_"+casetype+"zs_slxl", xl);
		dataMap.put("spxl_"+casetype+"zs_slxl_lastyear", xlLastYear);
		
		dataMap.put("spxl_"+casetype+"zs_rjjaxl", rjja);
		dataMap.put("spxl_"+casetype+"zs_rjjaxl_lastyear", rjjaLastYear);
		if(zs>zsLastYear) {
			dataMap.put("spxl_"+casetype+"zs_tb", "上升"+(NumUtil.toNxiaoshu(zs-zsLastYear,2)));//同比
		}else if(zs<zsLastYear) {
			dataMap.put("spxl_"+casetype+"zs_tb", "下降"+(NumUtil.toNxiaoshu(zsLastYear-zs,2)));//同比
		}else {
			dataMap.put("spxl_"+casetype+"zs_tb", "不变");//同比
		}
		if(kind.equals("中")) {
			Map zyxq = new HashMap();
			zyxq.put("fy", dataMap.get("fy")+"法院");
			zyxq.put("lastyearzs",zs);
			zyxq.put("yearzs",zsLastYear);
			zyxq.put("cz",NumUtil.toNxiaoshu(zs-zsLastYear,2));
			dataMap.put("zyxq", zyxq);
		}
    }
}
